<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
  {:widget_st('bootstrap')}
  {:widget_st('admin','css')}
  {:widget_st('jq','js')}
</head>
{:do_action('admin_head')}
<body>

<?php $api_domain = config('version.api_domain'); ?>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          {include file="public/show_updatesql_msg"}
            <a class="layui-btn layui-btn-sm layui-bg-orange" href="?status=1">可用插件</a>
<!--            <a class="layui-btn layui-btn-sm layui-bg-orange" href="?status=">全部插件</a>-->
        </div>
        <table class="layui-table">
            <colgroup>
                <col width="120">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>插件名</th>
                <th>路径名</th>
                <th>版本</th>
                <th>路径</th>
                <th>展示图</th>
                <th>系统状态</th>
                <th>运行状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
              <?php foreach($list as $k=>$vo){ ?>
                <?php $_plugin_class = 'addons\\'.$vo['plugin_name'].'\controller\Plugin'; ?>
                <tr>
                    <td>
                        {$vo['name']}
                        {$vo['version']}
                    </td>
                    <td>{$vo['plugin_name']}</td>
                    <td>
                      <img src="{$api_domain}/addons/zf_store_softclientv2.api/get_new_version?site={$client_config['site']}&token=11&soft_id={$vo['soft_id']}&ver={$vo['version']}&soft_key={$vo['soft_key']}" />
                    </td>
                    <td>./addons/{$vo['plugin_name']}</td>
                    <td style="text-align: center;"> 
                      <img src="{$vo['pic']}" style="height: 50px;" />
                    </td>
                    <td> 
                      {$vo['status']==1?'正常':''}
                      {$vo['status']==2?'未授权':''}
                      {$vo['status']==3?'代码缺失':''}
                      {$vo['status']==9?'已删除':''}
                      {$vo['status']==0?'已关闭':''}
                    </td> 
                    <td> 
                      <div class=" layui-form" lay-filter="component-form-element">        
                        <input type="checkbox" name="act_status" <?php echo $vo['act_status']==1?'checked':''; ?> lay-skin="switch" lay-text="开启|关闭" lay-filter="act_status_change" item="{$vo['id']}">
                      </div>
                    </td>     
                    <td>
                      <?php if(is_dir('./addons/'.$vo['plugin_name']) ){ ?>
                        <?php if($vo['menu_act']){ foreach($vo['menu_act'] as $kk=>$vv){   ?>
                          {$vv|raw}<br>
                        <?php } }else{ ?>
                          <?php if(class_exists($_plugin_class)){ ?>
                            <?php if(method_exists(new $_plugin_class(),'index')){ ?>
                              <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/index")' > 首页</a><br>
                            <?php } ?>
                            <?php if(method_exists(new $_plugin_class(),'setting')){ ?>
                              <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/setting")' > 配置</a><br>
                            <?php } ?>
                            <?php if(method_exists(new $_plugin_class(),'help')){ ?>
                              <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/help")' > 说明</a><br>
                            <?php } ?>
                          <?php } ?>
                        <?php } ?>

                        
                      <?php }else{ ?>
                      <span style="color: red">代码缺失</span>
                      <?php } ?>

                    </td>
                </tr>
              <?php }  ?>
            </tbody>
        </table>
        {$page|raw}

      </div>
    </div>
</div>


  {:widget_st('layui','js')}  
  {:widget_st('common','js')}
  <script>
 layui.use(['layer','upload','form'], function(){
    var $ = layui.$ 
    ,laypage = layui.laypage
    ,layer = layui.layer
    ,form = layui.form
    ,element = layui.element
    ,upload = layui.upload;
  
    form.on('switch(status_change)', function(data){
      var id = $(this).attr("item")
      var dbname = 'plugin'
      var status = this.checked ? '1' : '0'
      console.log(id)
      $.get("{:url('admin/common/is_switch')}",{id:id,dbname:dbname,status:status},function(res){
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
          }else{
            layer.msg(res.msg, {icon: 2});
          }
        },"json");
    });
    form.on('switch(act_status_change)', function(data){
      var id = $(this).attr("item")
      var dbname = 'plugin'
      var act_status = this.checked ? '1' : '0'
      console.log(id)
      $.get("{:url('admin/common/is_switch_actstatus')}",{id:id,dbname:dbname,act_status:act_status},function(res){
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
          }else{
            layer.msg(res.msg, {icon: 2});
          }
        },"json");
    });

});
  </script>
</body>
</html>
{:do_action('admin_js')}
<script>$('.detail-body').viewer();</script>